package com.time.on.device.model;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

import com.time.on.device.R;

public class DataConfig {

	public static final String PREFS_TIME_ON_DEVICE = "PrefsTimeOnDevice";
	public static final String PREFS_TIME_CONFIG = "PrefsTimeConfig";
	public static final String PREFS_MESSAGE_CONFIG = "PrefsMessageConfig";
	public static final Long TIME_DEFAULT_COUNT = 1200000l;// 1200s = 20'
	// true is started
	public static final String PREFS_START_OR_STOP = "PrefsStartOrStop";
	// true is locked
	public static final String PREFS_LOCK_SCREEN = "PrefsLockScreen";

	private SharedPreferences sharedPreferences;

	private Context context;

	public DataConfig(Context context) {
		this.context = context;
		sharedPreferences = this.context.getSharedPreferences(
				PREFS_TIME_ON_DEVICE, Context.MODE_PRIVATE);

	}

	public String getMessageConfig() {
		return sharedPreferences.getString(PREFS_MESSAGE_CONFIG, this.context
				.getResources().getString(R.string.inform_message_text));
	}

	public void saveMessageConfig(String messageConfig) {
		Editor editor = sharedPreferences.edit();
		editor.putString(PREFS_MESSAGE_CONFIG, messageConfig);
		editor.commit();
	}

	public Long getTimeConfig() {
		return sharedPreferences.getLong(PREFS_TIME_CONFIG, TIME_DEFAULT_COUNT);
	}

	public void saveTimeConfig(long timeConfig) {
		Editor editor = sharedPreferences.edit();
		editor.putLong(PREFS_TIME_CONFIG, timeConfig);
		editor.commit();
	}

	public void saveCurrentStatus(Boolean isStarted) {
		Editor editor = sharedPreferences.edit();
		editor.putBoolean(PREFS_START_OR_STOP, isStarted);// true is started
		editor.commit();
	}

	public boolean getCurrentStatus() {

		return sharedPreferences.getBoolean(PREFS_START_OR_STOP, false);
	}

	public void saveIsLocked(boolean isLocked) {
		Editor editor = sharedPreferences.edit();
		editor.putBoolean(PREFS_LOCK_SCREEN, isLocked);
		editor.commit();
	}

	public boolean isLockedScreen() {
		return sharedPreferences.getBoolean(PREFS_LOCK_SCREEN, false);
	}

}
